package com.mxpio.erp.common.jpa.model;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.inventory.entity.Warehouse;
import com.mxpio.erp.common.jpa.policy.NoticeCodeGeneratorPolicy;
import com.mxpio.erp.common.vo.OrderExcuteLineVo;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 通知单
 * @author MxpIO
 */
@Data
@MappedSuperclass
@EqualsAndHashCode(callSuper=false)
public abstract class Notice extends BaseEntity {

	private static final long serialVersionUID = 1L;

	public Notice(){
		super();
		this.setTypeCode(initTypeCode());
	}

	@Id
	@Column(name = "NOTICE_NO_", updatable = false)
	@Generator(policy = NoticeCodeGeneratorPolicy.class)
	@Schema(description = "通知单号")
	private String noticeNo;

	@Column(name = "NOTICE_STATUS_")
	@Schema(description = "单据状态")
	@Dict(dicCode = "ERP_INV_NOTICE_STATUS")
	private String noticeStatus;
	
	@Column(name = "ACCESS_TYPE_")
	@Schema(description = "出入类型")
	private String accessType;

	@Column(name = "TYPE_CODE_")
	@Schema(description = "通知类型")
	private String typeCode;
	
	@Column(name = "PICKING_TYPE_")
	@Schema(description = "通知单类别")
	//@Dict(dicCode = "ERP_WORKSHOP_PICKING_TYPE")
	@Dict(dicCode = "ERP_INV_WO_TYPE")//应该跟仓库类型保持一致
	private String pickingType;

	@Column(name = "BIZ_ORDER_NO_")
	@Schema(description = "业务单号")
	private String bizOrderNo;

	@Column(name = "WH_CODE_")
    @Schema(description = "仓库")
	@Dict(dicCode = "whCode", dicEntity = Warehouse.class, dicText = "whName")
    private String whCode;

	@Column(name = "NOTICE_DATE_")
	@Schema(description = "通知时间")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date noticeDate;
	
	public abstract List<? extends NoticeLine> getNoticeLines();
	
	public abstract String initTypeCode();
	
	public abstract NoticeLine createLine(OrderExcuteLineVo orderExcuteVo);

	@Transient
	private String tempInQualityOrderNo;//非检验通知单生成批次号时使用

}
